package cn.itcast.eshop.log.dao.impl;

import cn.itcast.eshop.log.entity.Log;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ConsoleLog implements cn.itcast.eshop.log.dao.impl.ISysLog {

    SimpleDateFormat sdf = new SimpleDateFormat("h:mm a"); // 12:08 PM

    @Override
    public void info(String msg) {
        // 1.封装日志对象
        String log = new Log(msg, INFO, sdf.format(new Date())).toString();
        // 2.打印日志数据到控制台
        System.out.println(log);
    }

    @Override
    public void warn(String msg) {
        // 1.封装日志对象
        String log = new Log(msg, WARN, sdf.format(new Date())).toString();
        // 2.打印日志数据到控制台
        System.out.println(log);
    }

    @Override
    public void error(String msg) {
        // 1.封装日志对象
        String log = new Log(msg, ERROR, sdf.format(new Date())).toString();
        // 2.打印日志数据到控制台
        System.out.println(log);
    }
}
